home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
ra2fls.zip
/
RA2FLS.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-11-26
|
13KB
|
486 lines
uses
dos, crt,
totFAST, totLINK, totLIST, totKEY, totSTR, totWIN,
totIO1, totIO2, totINPUT, totMISC;
{$I struct.110}
type
arearecord = record
name :string[30];
tag :word;
filepath :string[40];
end;
afmrecord = record
arearec :array[1..200] of arearecord;
bbsname :string[40];
daysnew :longint;
newfile :string[40];
outfile :string[40];
headerfile :string[40];
flsconfig :string[40];
end;
const
prog = ' RA2FLS ';
ver = '1.0 ';
afmconfigfile = 'RA2FLS.CFG';
var
f :file;
raconfigfile :string;
rafilesfile :string;
flsconfigfile :string;
afmrec :^afmrecord;
changed :boolean;
manager :formOBJ;
mainwin :winOBJ;
io_outfname,io_headerfname :lateralIOOBJ;
io_bbsname,io_newfiles :lateralIOOBJ;
io_flsconfig :lateralIOOBJ;
io_daysnew :intIOOBJ;
io_keys :controlKeysIOOBJ;
io_ok,io_esc :stripIOOBJ;
io_new :stripIOOBJ;
io_result :taction;
allfinished :boolean;
{ -------------------------------------------------------------------------- }
procedure msg(str :string);
begin
screen.writeplain(1,25,str);
end;
{ -------------------------------------------------------------------------- }
procedure errorexit( msg :string);
begin
writeln(^G+msg);
halt(1);
end;
{ -------------------------------------------------------------------------- }
procedure fixpaths;
var env :string;
begin
env := getenv('RA');
if env = '' then { read RA enviroment variable }
errorexit('Unable to read RA enviroment variable.');
raconfigfile := slasheddirectory(env)+raconfigfile; { add path to config file }
rafilesfile := slasheddirectory(env)+rafilesfile;
if not exist(raconfigfile) then
errorexit('Unable to open RA config file <'+raconfigfile+'>');
if not exist(rafilesfile) then
errorexit('Unable to open RA files file <'+rafilesfile+'>');
end;
{ -------------------------------------------------------------------------- }
procedure parseraconfig;
var numread :integer;
f :file;
buf :^configrecord;
begin
if maxavail < sizeof(configrecord)
then errorexit('Memory allocation error.');
new(buf); { malloc RAM }
assign(f,raconfigfile);
reset(f,1);
with buf^ do
begin
blockread(f,buf^,sizeof(buf^),numread);
afmrec^.bbsname := systemname+' - '+inttostr(address[0].zone)+':'+
inttostr(address[0].net)+'/'+inttostr(address[0].node)+'.'+
inttostr(address[0].point);
end;
dispose(buf);
close(f);
end;
{ -------------------------------------------------------------------------- }
procedure savecfg;
var numwritten :integer;
f :file;
tf :text;
l :byte;
begin
assign(f,afmconfigfile);
rewrite(f,1);
blockwrite(f,afmrec^,sizeof(afmrec^),numwritten);
close(f);
msg('Saving config file ... ');
with afmrec^ do
begin
assign(tf,flsconfig);
rewrite(tf);
writeln(tf,bbsname);
writeln(tf,daysnew);
writeln(tf,newfile);
writeln(tf,outfile);
writeln(tf,headerfile);
for l := 1 to 200 do
if (arearec[l].tag <> 0) then
writeln(tf,arearec[l].filepath,' <',arearec[l].tag,
'> ',arearec[l].name);
close(tf);
end;
end;
{ -------------------------------------------------------------------------- }
procedure initnewcfg;
var numwritten :integer;
l :word;
f :file;
begin
parseraconfig;
assign(f,afmconfigfile);
rewrite(f,1);
with afmrec^ do
begin
for l := 1 to 200 do
begin
arearec[l].name := '';
arearec[l].tag := 0;
arearec[l].filepath := '';
end;
daysnew := 31;
outfile := '635-534.LST';
headerfile := 'FILES.TOP';
newfile := 'NEWFILE.ASC';
flsconfig := 'FILELIST.CFG';
end;
blockwrite(f,afmrec^,sizeof(afmrec^),numwritten);
close(f);
msg('Making new config file ... ');
end;
{ -------------------------------------------------------------------------- }
procedure opencfg;
var numread :integer;
f :file;
begin
if not exist(afmconfigfile) then
begin
initnewcfg;
assign(f,afmconfigfile); { create new file }
reset(f,1);
blockread(f,afmrec^,sizeof(afmrec^),numread);
close(f);
if numread <> sizeof(afmrec^) then
errorexit('Data file corrupted <'+afmconfigfile+'>');
msg('Reading config file ... ');
end
else
begin { open existing file }
assign(f,afmconfigfile);
reset(f,1);
blockread(f,afmrec^,sizeof(afmrec^),numread);
close(f);
if numread <> sizeof(afmrec^) then
errorexit('Data file corrupted <'+afmconfigfile+'>');
msg('Reading config file ... ');
end;
end;
{ -------------------------------------------------------------------------- }
procedure updaterec;
begin
with afmrec^ do
begin
bbsname := io_bbsname.getvalue;
newfile := io_newfiles.getvalue;
outfile := io_outfname.getvalue;
headerfile := io_headerfname.getvalue;
daysnew := io_daysnew.getvalue;
flsconfig := io_flsconfig.getvalue;
end;
end;
{ -------------------------------------------------------------------------- }
procedure finishup;
begin
dispose(afmrec);
end;
{ -------------------------------------------------------------------------- }
procedure parsefilesfile(var itemlist :strdllobj);
var numread :integer;
f :file;
buf :^filesrecord;
count :integer;
scount :string[5];
begin
count := 1;
new(buf);
assign(f,rafilesfile);
reset(f,1);
repeat
blockread(f,buf^,sizeof(buf^),numread);
str(count:3,scount);
if (itemlist.add(scount+' - '+buf^.name) <> 0) then
errorexit('Memory allocation error.');
afmrec^.arearec[count].filepath := slasheddirectory(buf^.filepath);
inc(count);
until eof(f);
dispose(buf);
end;
{ -------------------------------------------------------------------------- }
{$F+}
procedure selectfiles;
var l :longint;
itemlist :strdllobj;
listwin :listlinkobj;
begin
itemlist.init;
parsefilesfile(itemlist);
with listwin do
begin
init;
assignlist(itemlist);
setcolwidth(39);
setcolors(lightcyan,blue+cyan shl 4,black+cyan shl 4);
win^.settitle(' File areas ');
win^.setsize(10,4,50,23,1);
win^.setboundary(1,1,80,23);
win^.setcolors(blue+cyan shl 4,blue+cyan shl 4,
black+cyan shl 4,yellow + cyan shl 4);
settagging(true);
for l := 1 to 200 do
if (afmrec^.arearec[l].tag <> 0) then
setstatus(l,0,true);
go;
remove;
if lastkey = kF10 then
begin
for l := 1 to itemlist.totalnodes do
if getstatus(l,0) then
begin
afmrec^.arearec[l].tag := l;
afmrec^.arearec[l].name := getstring(l,7,36);
end
else
begin
afmrec^.arearec[l].tag := 0;
afmrec^.arearec[l].name := '';
end;
savecfg;
end;
done;
end;
itemList.done;
end;
{$F-}
{ -------------------------------------------------------------------------- }
{$F+}
function cmdparser(var K:word; var X,Y:byte; var ID:word):tAction;
begin
case K of
kAltF : selectfiles;
end;
end;
{$F-}
{ -------------------------------------------------------------------------- }
procedure initvars;
begin
with io_bbsname do
begin
init(18,3,30,40);
setlabel('BBS name');
setvalue(afmrec^.bbsname);
setmessage(1,25,'The name of your BBS system');
end;
with io_headerfname do
begin
init(18,5,30,40);
setlabel('Header filename');
setvalue(afmrec^.headerfile);
setmessage(1,25,'The name of the <pre header> file');
end;
with io_outfname do
begin
init(18,7,30,40);
setlabel('Out filename');
setvalue(afmrec^.outfile);
setmessage(1,25,'The name of the <allfiles> file to be created');
end;
with io_newfiles do
begin
init(18,9,30,40);
setlabel('New files file');
setvalue(afmrec^.newfile);
setmessage(1,25,'The name of the <newfiles> file to be created');
end;
with io_daysnew do
begin
init(18,11,3);
setvalue(afmrec^.daysnew);
setlabel('Days new');
setmessage(1,25,'The number of days it takes to say that a file is new');
end;
with io_flsconfig do
begin
init(18,13,30,40);
setlabel('Config file');
setvalue(afmrec^.flsconfig);
setmessage(1,25,'The FILELIST configuration file');
end;
with io_ok do
begin
init(18,16,' OK ',Finished);
setmessage(1,25,'Save configuration and Exit.');
end;
with io_new do
begin
init(18,18,' Init ',stop1);
setmessage(1,25,'Initialise a new configuration');
end;
with io_esc do
begin
init(18,20,' ESC ',Escaped);
setmessage(1,25,'Abandon any changes and Exit.');
end;
io_keys.Init;
end;
{ -------------------------------------------------------------------------- }
procedure disposevars;
begin
io_outfname.done;
io_headerfname.done;
io_bbsname.done;
io_newfiles.done;
io_daysnew.done;
io_flsconfig.done;
io_ok.done;
io_esc.done;
io_new.done;
io_keys.done;
end;
{ -------------------------------------------------------------------------- }
procedure mainprocess;
begin
repeat;
initvars;
with mainwin do
begin
init;
setsize(1,1,51,23,1);
settitle(Prog+' '+Ver+' ... press Alt-F for files');
setclose(false);
setremove(true);
setcolors(cyan,white,white,lightblue);
draw;
end;
screen.clear(lightgray,chr(176));
with manager do
begin
init;
additem(io_keys);
additem(io_bbsname);
additem(io_headerfname);
additem(io_outfname);
additem(io_newfiles);
additem(io_daysnew);
additem(io_flsconfig);
additem(io_ok);
additem(io_new);
additem(io_esc);
setcharhook(cmdparser);
mouse.show;
io_result := go;
mouse.hide;
mainwin.done;
case io_result of
finished : begin
allfinished := true;
updaterec;
savecfg;
writeln('Saved changes');
end;
stop1 : begin
initnewcfg;
end;
else
begin
writeln('Abandoned changes');
allfinished := true;
end;
end;
disposevars;
done;
end;
if changed then savecfg;
until allfinished;
end;
{ -------------------------------------------------------------------------- }
procedure initialise;
begin
raconfigfile := 'CONFIG.RA';
rafilesfile := 'FILES.RA';
allfinished := false;
changed := false;
new(afmrec);
if afmrec = nil then
errorexit('Memory allocation error.');
with iotot^ do
begin
setcolmsg(white);
setcollabel(lightgray,yellow, yellow, yellow);
setcolfield(white,cyan, lightgray, lightgray);
setcolbutton(lightcyan,yellow, yellow, yellow);
setcolgroup(blue + cyan shl 4,yellow,white,yellow);
end;
fixpaths;
opencfg;
end;
{ -------------------------------------------------------------------------- }
begin
clrscr;
initialise;
mainprocess;
finishup;
end.